import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-05-13
 * Time: 19:13
 */
//给定一个整型数组, 实现冒泡排序(升序排序)
public class test {
    public static void fun(int[] arr){
        int p=0;
        for (int i = 1; i <arr.length ; i++) {
            for (int j = 0; j < arr.length - 1; j++) {
                if(arr[j]>arr[j+1]){
                    int c=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=c;
                    p=1;
                }
            }
            if(p==0)
                return;
        }
    }
    public static void main(String[] args) {
        int[] arr={1,4,7,2,5,8,3,6,9};
        fun(arr);
        String str=Arrays.toString(arr);
        System.out.println(str);
    }
}
